package com.mes.basicdata.dao;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.mes.basicdata.dao.iface.IOperationDao;
import com.mes.basicdata.dao.iface.IOperationMeasurementDao;
import com.mes.basicdata.domain.Operation;
import com.mes.basicdata.domain.OperationMeasurement;
import com.mes.common.dao.BasicDao;

@Repository
public class OperationMeasurementDao extends BasicDao<OperationMeasurement> implements IOperationMeasurementDao{
	@Autowired
	private IOperationDao operationDao;
	
	@Override
	public List<OperationMeasurement> getOperationMeasurementListByOperationUid(String operationUid) throws Exception {
		Operation operation = operationDao.getById(operationUid);
		Set<OperationMeasurement> operationMeasurements = operation.getOperationMeasurements();
		List<OperationMeasurement> list = new ArrayList<OperationMeasurement>();
		
		for (OperationMeasurement om : operationMeasurements) {
			list.add(om);
		}
		return list;
	}	
}
